home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / Mesa-2.2 / include / GL / xmesa.h < prev   
Encoding:
C/C++ Source or Header  |  1996-10-30  |  6.3 KB  |  247 lines

  1. /* $Id: xmesa.h,v 1.3 1996/10/30 03:13:01 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  2.1
  6.  * Copyright (C) 1995-1996  Brian Paul
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25.  * $Log: xmesa.h,v $
  26.  * Revision 1.3  1996/10/30 03:13:01  brianp
  27.  * incremented version to 2.1
  28.  *
  29.  * Revision 1.2  1996/09/20 02:56:45  brianp
  30.  * updated for new XMesaContext, XMesaVisual and XMesaBuffer datatypes
  31.  *
  32.  * Revision 1.1  1996/09/13 01:26:41  brianp
  33.  * Initial revision
  34.  *
  35.  */
  36.  
  37.  
  38. /*
  39.  * Mesa/X11 interface.  This header file serves as the documentation for
  40.  * the Mesa/X11 interface functions.
  41.  */
  42.  
  43.  
  44. /* Sample Usage:
  45.  
  46. In addition to the usual X calls to select a visual, create a colormap
  47. and create a window, you must do the following to use the X/Mesa interface:
  48.  
  49. 1. Call XMesaCreateVisual() to make an XMesaVisual from an XVisualInfo.
  50.  
  51. 2. Call XMesaCreateContext() to create an X/Mesa rendering context, given
  52.    the XMesaVisual.
  53.  
  54. 3. Call XMesaCreateWindowBuffer() to create an XMesaBuffer from an X window
  55.    and XMesaVisual.
  56.  
  57. 4. Call XMesaMakeCurrent() to bind the XMesaBuffer to an XMesaContext and
  58.    to make the context the current one.
  59.  
  60. 5. Make gl* calls to render your graphics.
  61.  
  62. 6. Use XMesaSwapBuffers() when double buffering to update the buffer.
  63.  
  64. 7. Before the X window is destroyed, call XMesaDestroyBuffer().
  65.  
  66. 8. Before exiting, call XMesaDestroyVisual and XMesaDestroyContext.
  67.  
  68. See the demos/xdemo.c and xmesa1.c files for examples.
  69. */
  70.  
  71.  
  72.  
  73.  
  74. #ifndef XMESA_H
  75. #define XMESA_H
  76.  
  77.  
  78. #ifdef __cplusplus
  79. extern "C" {
  80. #endif
  81.  
  82.  
  83. #include <X11/Xlib.h>
  84. #include <X11/Xutil.h>
  85. #include "GL/gl.h"
  86.  
  87. #ifdef AMIWIN
  88. #include <pragmas/xlib_pragmas.h>
  89. extern struct Library *XLibBase;
  90. #endif
  91.  
  92.  
  93. #define XMESA_MAJOR_VERSION 2
  94. #define XMESA_MINOR_VERSION 1
  95.  
  96.  
  97.  
  98. /*
  99.  * Values passed to XMesaGetString:
  100.  */
  101. #define XMESA_VERSION 1
  102. #define XMESA_EXTENSIONS 2
  103.  
  104.  
  105.  
  106. typedef struct xmesa_context *XMesaContext;
  107.  
  108. typedef struct xmesa_visual *XMesaVisual;
  109.  
  110. typedef struct xmesa_buffer *XMesaBuffer;
  111.  
  112.  
  113.  
  114.  
  115. /*
  116.  * Create a new X/Mesa visual.
  117.  * Input:  display - X11 display
  118.  *         visinfo - an XVisualInfo pointer
  119.  *         rgb_flag - GL_TRUE = RGB mode,
  120.  *                    GL_FALSE = color index mode
  121.  *         alpha_flag - alpha buffer requested?
  122.  *         db_flag - GL_TRUE = double-buffered,
  123.  *                   GL_FALSE = single buffered
  124.  *         depth_size - requested bits/depth values, or zero
  125.  *         stencil_size - requested bits/stencil values, or zero
  126.  *         accum_size - requested bits/component values, or zero
  127.  *         ximage_flag - GL_TRUE = use an XImage for back buffer,
  128.  *                       GL_FALSE = use an off-screen pixmap for back buffer
  129.  * Return;  a new XMesaVisual or 0 if error.
  130.  */
  131. extern XMesaVisual XMesaCreateVisual( Display *display,
  132.                                       XVisualInfo *visinfo,
  133.                                       GLboolean rgb_flag,
  134.                                       GLboolean alpha_flag,
  135.                                       GLboolean db_flag,
  136.                                       GLboolean ximage_flag,
  137.                                       GLint depth_size,
  138.                                       GLint stencil_size,
  139.                                       GLint accum_size,
  140.                                       GLint level );
  141.  
  142. /*
  143.  * Destroy an XMesaVisual, but not the associated XVisualInfo.
  144.  */
  145. extern void XMesaDestroyVisual( XMesaVisual v );
  146.  
  147.  
  148.  
  149. /*
  150.  * Create a new XMesaContext for rendering into an X11 window.
  151.  *
  152.  * Input:  visual - an XMesaVisual
  153.  *         share_list - another XMesaContext with which to share display
  154.  *                      lists or NULL if no sharing is wanted.
  155.  * Return:  an XMesaContext or NULL if error.
  156.  */
  157. extern XMesaContext XMesaCreateContext( XMesaVisual visual,
  158.                                         XMesaContext share_list );
  159.  
  160.  
  161. /*
  162.  * Destroy a rendering context as returned by XMesaCreateContext()
  163.  */
  164. extern void XMesaDestroyContext( XMesaContext c );
  165.  
  166.  
  167. /*
  168.  * Create an XMesaBuffer from an X window.
  169.  */
  170. extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v, Window w );
  171.  
  172.  
  173. /*
  174.  * Create an XMesaBuffer from an X pixmap.
  175.  */
  176. extern XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v, Pixmap p,
  177.                                             Colormap c );
  178.  
  179.  
  180. /*
  181.  * Destroy an XMesaBuffer, but not the corresponding window or pixmap.
  182.  */
  183. extern void XMesaDestroyBuffer( XMesaBuffer b );
  184.  
  185.  
  186. /*
  187.  * Bind a buffer to a context and make the context the current one.
  188.  */
  189. extern GLboolean XMesaMakeCurrent( XMesaContext c, XMesaBuffer b );
  190.  
  191.  
  192. /*
  193.  * Return a handle to the current context.
  194.  */
  195. extern XMesaContext XMesaGetCurrentContext( void );
  196.  
  197.  
  198. /*
  199.  * Return handle to the current buffer.
  200.  */
  201. extern XMesaBuffer XMesaGetCurrentBuffer( void );
  202.  
  203.  
  204. /*
  205.  * Swap the front and back buffers for the given buffer.  No action is
  206.  * taken if the buffer is not double buffered.
  207.  */
  208. extern void XMesaSwapBuffers( XMesaBuffer b );
  209.  
  210.  
  211. /*
  212.  * Return a pointer to the the Pixmap or XImage being used as the back
  213.  * color buffer of an XMesaBuffer.  This function is a way to get "under
  214.  * the hood" of X/Mesa so one can manipulate the back buffer directly.
  215.  * Input:  b - the XMesaBuffer
  216.  * Output:  pixmap - pointer to back buffer's Pixmap, or 0
  217.  *          ximage - pointer to back buffer's XImage, or NULL
  218.  * Return:  GL_TRUE = context is double buffered
  219.  *          GL_FALSE = context is single buffered
  220.  */
  221. extern GLboolean XMesaGetBackBuffer( XMesaBuffer b,
  222.                                      Pixmap *pixmap, XImage **ximage );
  223.  
  224.  
  225.  
  226. /*
  227.  * Flush/sync a context
  228.  */
  229. extern void XMesaFlush( XMesaContext c );
  230.  
  231.  
  232.  
  233. /*
  234.  * Get an X/Mesa-specific string.
  235.  * Input:  name - either XMESA_VERSION or XMESA_EXTENSIONS
  236.  */
  237. extern const char *XMesaGetString( XMesaContext c, int name );
  238.  
  239.  
  240.  
  241. #ifdef __cplusplus
  242. }
  243. #endif
  244.  
  245.  
  246. #endif
  247.